# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Joost Bremmer <contact at madeofmagicandwires dot online>
# Contributor: Eliezio Oliveira <eliezio@pm.me>
# Contributor: Matthew Gamble <internet@matthewgamble.net>

pkgname=sad
pkgver=0.4.22
pkgrel=1
pkgdesc='Space Age seD'
arch=('loong64' 'x86_64')
url='https://github.com/ms-jpq/sad'
license=('MIT')
depends=('gcc-libs')
makedepends=('git' 'rust')
optdepends=(
  'fzf: for tui usage'
  'diff-so-fancy: for diff colourizer'
  'git-delta: for diff colourizer'
)
options=('!lto')
_commit='3d709fc2d8c1f504e92378c46f19360b91c65828'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  # download dependencies
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname"
  cargo build --frozen --release --all-features
}

check() {
  cd "$pkgname"
  cargo test --frozen --all-features
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" "target/release/$pkgname"

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
}

# vim: set ts=2 sts=2 sw=2 et :
